#include "QtCard.h"
#include <QMouseEvent>

QtCard::QtCard(QWidget *parent, Qt::WFlags flags): QWidget(parent, flags)
{
	ui.setupUi(this);

	SetEmpty();
}

QtCard::~QtCard()
{

}
bool QtCard::IsEmpty() const
{
	return empty;
}

void QtCard::SetEmpty()
{
	empty = true;
	ui.imageLabel->setPixmap( QPixmap("empty.png"));
}

void QtCard::SetCard(const Card& newCard)
{
	card = newCard;
	empty = false;

	if(card.GetForward())
		ui.imageLabel->setPixmap( QPixmap("forward.png"));
	else if(card.GetBackward())
		ui.imageLabel->setPixmap( QPixmap("backward.png"));
	else if(card.GetLeftTurn())
		ui.imageLabel->setPixmap( QPixmap("leftturn.png"));
	else if(card.GetRightTurn())
		ui.imageLabel->setPixmap( QPixmap("rightturn.png"));
}

const Card& QtCard::GetCard() const
{
	return card;
}

void QtCard::mousePressEvent(QMouseEvent *e)
{
	if (!IsEmpty())
	{
		emit ClickedCard(this);
	}
}

